var sass = require('sass');
const fse = require('fs-extra');
const config = require('../config');

async function renderScss({ source, target }) {
  const buffer = await new Promise((resolve, reject) => {
    sass.render({ file: source, outputStyle: 'compressed' }, function(err, result) {
      if (err) return reject(err);
      resolve(result.css);
    });
  });
  await fse.outputFile(target, buffer);
}

module.exports = async () => {
  await renderScss(config.style.post);
};
